package cn.wit.luohui.day11;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;

import org.junit.Test;

public class DemoChar {
	@Test
	public void test() throws UnsupportedEncodingException {
	char c='A';
	char z='中';
	System.out.println(z);//中
	
//	String s="中";
//	System.out.println(Arrays.toString(s.getBytes()));//3个字节
//	System.out.println(Arrays.toString(s.getBytes("utf-8")));//3
//	System.out.println(Arrays.toString(s.getBytes("gbk")));//2
//	
//	System.out.println((int)'A');//65
//	System.out.println((char)256);//输出其他码表
//	System.out.println((char)66);//B
//	
//	System.out.println(Arrays.toString("A".getBytes("gbk")));//[65]
	}
	@Test
	public void test2() {
		try(FileOutputStream out=new FileOutputStream("a.txt");){
			out.write('A');
		//字节流，一次写一个字节，写中文的时候可能会丢失信息
			out.write('中');
			
		} catch (IOException e) {
			
			e.printStackTrace();
		}
	}
@Test
public void test3() {
	try(FileInputStream in=new FileInputStream("a.txt");){
		byte[] bytes=new byte[10];
		int count=in.read(bytes);
	System.out.println(count);
	} catch (IOException e) {
		
	}
}
}
